package com.jdk.demo.thread.reentrantLock;

import java.util.concurrent.locks.ReentrantLock;

public class Demo2 {

	private static int count = 0;

	public static void main(String[] args) throws InterruptedException {
		ReentrantLock lock = new ReentrantLock();
		for(int i=0; i<10; i++){
			Thread t = new Thread(() -> {
				System.out.println(lock.tryLock());
				try {
					Thread.sleep(100);
				} catch (Exception e) {
					e.printStackTrace();
				}
				count++;
				lock.unlock();
			});
			t.start();
		}
		Thread.sleep(2000);
		System.out.println(count);
	}

}
